﻿using Md.Api.Entity.ModelDB;

namespace Md.Petapoco.Repositories.MdTrainingEducation;
/// <summary>
/// 系统用户岗位关联仓储
/// </summary>
public class SysUserPostRep : BaseRep<SysUserPostModel>
{
    /// <summary>
    /// 通过用户编号获取(系统用户岗位关联)列表
    /// </summary>
    /// <param name="userId">用户编号</param>
    /// <returns>IEnumerable<SysUserPostModel></returns>
    public IEnumerable<SysUserPostModel> GetSysUserPostListByUserId(long userId)
    {
        #region ===sql===
        string sqlStr = string.Format(@"
            select `id`
                  ,`user_id`
                  ,`post_id`
            from `sys_user_post`
            where 1 = 1 and `user_id` = @0
         ");
        #endregion

        return MdTrainingEducationDB.GetInstance().Query<SysUserPostModel>(sqlStr, userId);
    }
    /// <summary>
    /// 通过用户编号删除(系统用户岗位关联)数据
    /// </summary>
    /// <param name="userId">用户编号</param>
    /// <returns>int</returns>
    public int DeletePostByUserId(long userId)
    {
        string strSql = string.Format(@"
            where 1 = 1 and `user_id` = @0
        ");

        return MdTrainingEducationDB.GetInstance().Delete<SysUserPostModel>(strSql, userId);
    }
}

